-- ejercicio 8
doubleAll :: [Int] -> [Int]
doubleAll xs = [x*2 | x <- xs]

doubleAll1 :: [Int] -> [Int]
doubleAll1 [] = []
doubleAll1 (x:xs) = (x*2) : doubleAll1 xs

-- ejercicio 10

divisors :: Int	-> [Int]
divisors n = divisors_aux n [1..n]
divisors_aux :: Int -> [Int] -> [Int]
divisors_aux n xs = [ x | x <- xs, (n `mod` x) == 0]

divisors1 :: Int -> [Int]
divisors1 n = [ x | x <- xs, (n `mod` x) == 0]
	where xs = [1..n]

divisors2 :: Int -> [Int]	
divisors2 n = [ x | x <- xs, ((==0).(mod n) )x]
	where xs = [1..n]	

isprime :: Int -> Bool
isprime n = (length (divisors n)) == 2

isprime1 :: Int -> Bool
isprime1 n = ((length . divisors) n) == 2

isprime2 :: Int -> Bool
isprime2 n = ((==2) . (length . divisors)) n

-- ejercicio 12
matches :: Int -> [Int] -> [Int]
matches _ [] = []
matches n (x:xs) 
	| n == x	= x : matches n xs
	| otherwise = matches n xs

